/**
	Authors: Jesse Phillips, he_the_great@yahoo.com
	Created: October 8, 2006
*/

module tag;

class Tag
{
public:
	char[] name; int count = 1; 

	this(char[] name)
	{
		this.name = name;
	}//end constructor

	char[] toString()
	{
		return name;
	}//end toString method
}//end class Tag

public class TagGroup
{
private:
	Tag[] tags;
	int tagNum = 0;

public:
	int level = -1;
	this()
	{
		tags = new Tag[50];
	}//end default constructor
	this(int lvl)
	{
		tags = new Tag[50];
		level = lvl;
	}//end explicit constructor
	Tag[] getTags()
	{
		return tags;
	}//end method getTags

	void addTag(Tag tag)
	{
		tags[tagNum++] = tag;
	}//end method addTag

	bool empty()
	{
		if(tagNum == 0) return true;
		return false;
	}//end method empty

//	void addTags(char[][] tags)
//	{
//		foreach(char[] s; tags)
//			this.tags[tagNum++] = s;
//	}

	Tag hasTag(Tag tag)
	{
		foreach(t; tags)
			if(t !is null && tag !is null)
			if(t.name == tag.name)
				return t;
		return null;
	}//end method hasTag (Tag)

	Tag hasTag(char[] tag)
	{
		foreach(t; tags)
			if(t !is null)
			if(t.name == tag)
				return t;
		return null;
	}//end method hasTag (char[])

	char[] toString()
	{
		char[] result = "";
		if(tags[0] !is null)
				result ~= tags[0].name;
		foreach(t;tags)
			if(t !is null && t.name != tags[0].name)
				result ~= ", "~t.name;
		return result;
	}//end toString method
}//end class TagGroup
